package bb.lanxing.ali.behavior;

import com.umeng.socialize.net.dplus.CommonNetImpl;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;

public class DefaultBehavior implements Behavior {
    private final SimpleDateFormat BHV_DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private final Map<String, String> properties = new HashMap();
    private BehaviorSubmitter submitter;

    public DefaultBehavior(BehaviorSubmitter behaviorSubmitter) {
        this.submitter = behaviorSubmitter;
    }

    public DefaultBehavior() {
    }

    @Override
    public Map<String, String> getProperties() {
        return this.properties;
    }

    @Override
    public Behavior property(String str, String str2) {
        this.properties.put(str, str2);
        return this;
    }

    @Override
    public Behavior action(String str) {
        return property("bhv_type", str);
    }

    @Override
    public Behavior datetime(long j) {
        return property("bhv_datetime", this.BHV_DATETIME_FORMATTER.format(j));
    }

    @Override
    public Behavior amount(double d) {
        return property("bhv_amt", String.valueOf(d));
    }

    @Override
    public Behavior position(String str) {
        return property(CommonNetImpl.POSITION, str);
    }

    @Override
    public Behavior positionType(String str) {
        return property("pos_type", str);
    }

    @Override
    public Behavior count(double d) {
        return property("bhv_cnt", String.valueOf(d));
    }

    @Override
    public Behavior content(String str) {
        return property("content", str);
    }

    @Override
    public Behavior media(String str) {
        return property("media_type", str);
    }

    @Override
    public Behavior item(String str) {
        return property("item_id", str);
    }

    @Override
    public Behavior trace(String str) {
        return str == null ? this : property("trace_id", str);
    }

    @Override
    public Behavior user(String str) {
        return property("user_id", str);
    }

    @Override
    public void submit() {
        BehaviorSubmitter behaviorSubmitter = this.submitter;
        if (behaviorSubmitter != null) {
            behaviorSubmitter.submit(this);
        }
    }

    @Override
    public Behavior view() {
        return action("view");
    }

    @Override
    public Behavior click() {
        return action("click");
    }

    @Override
    public Behavior collect() {
        return action("collect");
    }

    @Override
    public Behavior uncollect() {
        return action("uncollect");
    }

    @Override
    public Behavior searchClick() {
        return action("search_click");
    }

    @Override
    public Behavior comment() {
        return action("comment");
    }

    @Override
    public Behavior share() {
        return action("share");
    }

    @Override
    public Behavior like() {
        return action("like");
    }

    @Override
    public Behavior dislike() {
        return action("dislike");
    }

    @Override
    public Behavior grade() {
        return action("grade");
    }

    @Override
    public Behavior consume() {
        return action("consume");
    }

    @Override
    public Behavior use() {
        return action("use");
    }

    @Override
    public Behavior create() {
        return action("create");
    }

    @Override
    public Behavior download() {
        return action("download");
    }

    @Override
    public Behavior join() {
        return action("join");
    }

    public String toString() {
        return "DefaultBehavior{properties=" + this.properties + '}';
    }
}
